﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKRoomInspection.Model;
using YJKRoomInspection.ProgramArchitecture;
using YJKRoomInspection.Properties;
using YJKRoomInspection.Utiltiy;
using YJKRevitKernel.FormUtility.ModelessFormControlSuite.ControlLayer;

namespace YJKRoomInspection.ShowDataForm.ModellessFrame
{
	internal class FrontRoomListFormModellessManger : BaseLoopMangerNoneSwitch
	{
		public FrontRoomListFormModellessManger(FrontRoomListForm_ModellessNoneSwitch inputForm) : base(inputForm.UiDoc, inputForm, inputForm.RevitHandle, null)
		{
		}

		protected override void DoBeforeContinue()
		{
			if (this.m_useForm is FrontRoomListForm_ModellessNoneSwitch)
			{
				(this.m_useForm as FrontRoomListForm_ModellessNoneSwitch).DoBeforeContinue();
			}
		}

		protected override void DoAfterWhile()
		{
			List<AdapteRoomResulePacker> list = new List<AdapteRoomResulePacker>();
			List<Element> list2 = new List<Element>();
			List<InsertData> list3 = new List<InsertData>();
			if (this.m_useForm is FrontRoomListForm_ModellessNoneSwitch)
			{
				(this.m_useForm as FrontRoomListForm_ModellessNoneSwitch).ChangeFilledRegionVisible(new List<int>());
				list.AddRange((this.m_useForm as FrontRoomListForm_ModellessNoneSwitch).LstPackerNeedAddValue);
			}
			foreach (AdapteRoomResulePacker adapteRoomResulePacker in list)
			{
				if (adapteRoomResulePacker.GetElement() != null)
				{
					list2.Add(adapteRoomResulePacker.GetElement());
					list3.Add(new InsertData
					{
						FrontRoomType = adapteRoomResulePacker.AddRoomType
					});
				}
			}
			List<int> list4 = new List<int>();
			foreach (Element element in list2)
			{
				if (element != null && element is Room)
				{
					list4.Add(element.Id.IntegerValue);
				}
			}
			PublicYJKRoomInspection.LstFrontRoomIds.AddRange(list4);
			InsertDataToRoom.WriteToElement(list2, Resources.GUID, list3);
			base.DoAfterWhile();
		}
	}
}
